package 牛客周赛.牛客周赛Round87;

import java.util.Scanner;

/**
 * @Title: B
 * @Author 贾金博
 * @Package 牛客周赛.牛客周赛Round87
 * @Date 2025/4/7 下午4:38
 * @description: This is B
 */
public class B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();

        while(t -- > 0 ) {
            String s = "";
            s = sc.next();
            int ret = 0;
            for(int i = 0; i < s.length() - 1; i++) {

                // 开始进行截取
                int t1 = Integer.parseInt(s.substring(0, i + 1));
                int t2 = Integer.parseInt(s.substring(i + 1));
                ret = Math.max(ret, t1 + t2);
            }

            System.out.println(ret);

        }
    }
}
